var RunMainLayer = cc.Layer.extend({
	lead:null,
	real:null,
    ctor:function () {
        this._super();
        ll.run = null;
        ll.main = this;
        this.loadTip();
        this.loadTool();
        this.loadFlow();
        if(gg.teach_type == TAG_LEAD){
        	this.loadSelect();	
        } else {
        	this.loadRun(true);
        }
// this.loadTV();
        return true;
    },
    loadTV:function(){
    	tv = new cc.Sprite();
    	tv.setColor(cc.color(155,155,155));
    	tv.setTextureRect(cc.rect(0,0,560,220));
    	tv.setPosition(640,595);
    	this.addChild(tv);

    	var self = this;
// var url =
// "http://teach-platform.oss-cn-hangzhou.aliyuncs.com/head/sakura.jpg";
// cc.loader.loadImg(url, {isCrossOrigin : false }, function(err,img){
// if (cc.sys.platform == cc.sys.DESKTOP_BROWSER) {
// tv.setTexture(url);
// } else {
// tv.initWithTexture(img);
// }
// });
    },
    loadTip:function(){
    	ll.tip = new TipLayer(this);
    },
    loadTool:function(){
    	ll.tool = new ToolLayer(this);
    	ll.tool.hiddleChapter();
    },
    loadSelect:/**
				 * 加载选择页面
				 */
    function(){
    	ll.select = new SelectLayer(this);
    },
    loadSelect2:/**
				 * 并定位,当前节点
				 */
    function(){
    	ll.select = new SelectLayer(this);
    	ll.select.gotoL();
    },
    destroySelect:/**
					 * 销毁选择责页面
					 */
    function(){
    	if(ll.select != null){
    		ll.select.destroy();
    	}
    },
    loadRun:function(start){
    	if(start){
    		gg.flow.start();
    		ll.run.removeFromParent(true);
    		ll.run = null;
    	}
    	if(ll.run != null){
    		ll.run.destroy();
    	}
    	ll.tool.showChapter();
    	var no = gg.flow.flow.nodeNo;
    	switch(no){
    	case 1:
    		ll.run = new RunLayer1(this);
    		break;
    	case 2:
    		ll.run = new RunLayer2(this);
    		break;
    	case 3:
    		ll.run = new RunLayer3(this);
    		break;
    	case 4:
    		ll.run = new RunLayer4(this);
    		break;
    	case 5:
    		ll.run = new RunLayer5(this);
    		break;
    	case 6:
    		ll.run = new RunLayer6(this);
    		break;
    	}
    	if(gg.teach_type == TAG_LEAD){
    		ll.run.showTitle();
    	}
    },
    loadFlow:function(){
    	gg.flow.setMain(this);
// gg.flow.start();
    },
    over: function (){
    	ll.tip.over();
    	this.scheduleOnce(function(){
    		gg.synch_l = false;
    		$.runScene(new FinishScene());
    	},2);
    	// 提交成绩
    	net.saveScore();
    },
});
